package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkspaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * @author 苏成博
 * @date 2023-02-15 16:01
 */
@RestController
@Slf4j
@Api(tags = "商店控制器")
@RequestMapping("/admin/workspace")
public class WorkspaceController {
    @Autowired
    private WorkspaceService workspaceService;
    @GetMapping("/businessData")
    public Result<BusinessDataVO> getTodayBusinessData(){
        LocalDate now = LocalDate.now();
        LocalDateTime localDateTimeMin = now.atTime(LocalTime.MIN);
        LocalDateTime localDateTimeNow = LocalDateTime.now();
        BusinessDataVO businessDataVO=workspaceService.getTodayBusinessData(localDateTimeMin,localDateTimeNow);
        return Result.success(businessDataVO);
    }
    @GetMapping("/overviewOrders")
    public Result<OrderOverViewVO> getTodayOverviewOrders(){
        OrderOverViewVO orderOverViewVO=workspaceService.getTodayOverviewOrders();
        return Result.success(orderOverViewVO);
    }
    @GetMapping("/overviewDishes")
    public Result<DishOverViewVO> getTodayOverviewDishes(){
        DishOverViewVO dishOverViewVO=workspaceService.getTodayOverviewDishes();
        return Result.success(dishOverViewVO);
    }
    @GetMapping("/overviewSetmeals")
    public Result<SetmealOverViewVO> getTodayOverviewSetmeals(){
        SetmealOverViewVO setmealOverViewVO=workspaceService.getTodayOverviewSetmeals();
        return Result.success(setmealOverViewVO);
    }

}
